<template>
	<view class="cm-tab">
		<view @click="selectTab(index,item)" :class="{'tab-item-active':curTab == index}" class="tab-item" v-for="(item,index) in list" :key="index">
			{{item.label}}
		</view>
	</view>
</template>
<script>
	export default {
		name: "cmTab",
		components: {},
		props: {
			list: {
				type: Array,
				default: () => []
			},
			value: {
				type: [Number,String],
				default: 0
			}
		},
		data() {
			return {
				curTab: 0
			};
		},
		methods: {
			selectTab(idx,val) {
				this.curTab = idx
				this.$emit('change',idx,val)
			}
		},
		mounted() {},
	};
</script>
<style lang="less" scoped>
	.cm-tab {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-around;

		.tab-item {
			padding: 10rpx 20rpx;
			font-size: 24rpx;
			color: #868686;
		}

		.tab-item-active {
			border-radius: 20rpx;
			color: #0085FF;
			background: #D2EBFF;
		}
	}
</style>
